<?php
namespace My\Controller;

use Utuo\BackgroundController;

class MicroShowConfigController extends BackgroundController {
    
    public function _initialize() {
        $this->setControllerTitle("微秀基础配置");
        $this->setActionTitle(array(
            'index' => "微秀基础配置",            
        ));
        $this->setActionNav("index");
    }
    
    /**
     * 微秀基础配置(non-PHPdoc)
     * @see \Utuo\BackgroundController::indexAction()
     */
    public function indexAction() {
        $m = M("MicroShowConfig");
        $microShowConfig = $m->where("cid=%d", $this->aid)->find();
        if ( !$microShowConfig ) {
            $microShowConfig = array(
              'cid' => $this->aid,  
            );
            $microShowConfig['id'] = $m->add($microShowConfig);
        }
        $this->assign("microShowConfig", $microShowConfig);
        $this->display();
    }
    
    /**
     * 保存配置
     */
    public function savePostAction() {
        $m = M("MicroShowConfig");
        if ( false !== $m->create() ) {
            false !== $m->save() and $this->ajaxSuccess("保存成功");
        }
        $this->ajaxSuccess("保存失败");
    }
    
}